package com.shf.lease.web.admin.converter;

import com.shf.lease.enums.ItemType;

import org.springframework.core.convert.converter.Converter;
import org.springframework.stereotype.Component;

/**
 * @author 叶枫
 * @date 2024/7/4.
 */

@Component
public class StringToItemTypeConverter implements Converter<String,ItemType> {


    @Override
    public ItemType convert(String source) {
        for (ItemType value : ItemType.values()) {
            if (value.getCode().equals(Integer.valueOf(source))) {
                return value;
            }
        }
        throw new IllegalArgumentException("没有找到对应的枚举");
    }
}
